<template>
    <div class="searchContainer">
        <span class="inputLabel">路由文根</span>
        <el-input v-model="routeRootPathSearchData.routeRootPath" placeholder="路由文根" class="searchInfoInput"></el-input>

        <span class="inputLabel">路由文根名称</span>
        <el-input v-model="routeRootPathSearchData.routeRootName" placeholder="路由文根名称" class="searchInfoInput"></el-input>

        <span class="inputLabel">关联组件</span>
        <el-select v-model="routeRootPathSearchData.componentId" placeholder="关联组件" class="searchInfoInput" clearable>
            <el-option :label="item.componentCnName" :value="item.id" v-for="item in componentList" :key="item.id"/>
        </el-select>

        <el-button type="primary" icon="SearchOutlined" class="searchButtonClass" :loading="searchLoading" @click="queryComponentInfo()">搜索</el-button>
        <el-button icon="RedoOutlined" @click="resetInput()">重置</el-button>
    </div>
</template>

<script>
import {routeRootPathInfoQuery} from "@/request/routeRootPath";
import {componentInfoQueryNoContent} from "@/request/components";

export default {
    name: "RouteRootPathSearch",
    data() {
        return {
            componentList: [],
            searchLoading: false
        }
    },
    methods: {
        queryComponentInfo() {
            this.searchLoading = true
            routeRootPathInfoQuery(this.routeRootPathSearchData).then(res => {
                this.$store.state.routeRootPathDataList = res.data
                this.searchLoading = false
            }).catch(res => {
                this.this.searchLoading = false
            })
        },
        resetInput() {
            this.$store.state.routeRootPathSearchData = {
                routeRootPath: "",
                pageInfo: {
                    pageIndex: 1,
                    pageSize: 10
                }
            };
        }
    },
    computed: {
        routeRootPathSearchData() {
            return this.$store.state.routeRootPathSearchData;
        }
    },
    created() {
        let param = {
            pageInfo: {
                pageIndex: 1,
                pageSize: 10000
            },
            componentType: "CUSTOM"
        }
        componentInfoQueryNoContent(param).then(res => {
            this.componentList = res.data.dataList;
        })
    }
}
</script>

<style scoped lang="less">
.searchContainer {
    width: 100%;
    height: 10%;
    .searchInfoInput {
        width: 15%;
        padding-left: 1%;
    }
    .inputLabel {
        padding-left: 1%;
        font-weight: 700;
        font-size: 15px;
        color: #606266;
    }
    .searchButtonClass {
        margin-left: 1%;
    }
}
</style>